//
//  JKRFeedDetailToolView.m
//  JKRFeedDemo
//
//  Created by Lucky on 2017/12/10.
//  Copyright © 2017年 Lucky. All rights reserved.
//

#import "JKRFeedDetailToolView.h"

@interface JKRFeedDetailToolView ()

@property (nonatomic, strong) UIImageView *backgroundImageView;
@property (nonatomic, strong) UIButton *commentButton;
@property (nonatomic, strong) UIButton *voteButton;
@property (nonatomic, strong) UIButton *shareButton;

@end

@implementation JKRFeedDetailToolView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    [self addSubview:self.backgroundImageView];
    [self addSubview:self.commentButton];
    [self addSubview:self.voteButton];
    [self addSubview:self.shareButton];
    return self;
}

- (void)commentButtonClick:(UIButton *)sender {
    [self.delegate toolViewDidClickCommentButton];
}

- (UIImageView *)backgroundImageView {
    if (!_backgroundImageView) {
        _backgroundImageView = [UIImageView new];
        _backgroundImageView.frame = self.bounds;
        _backgroundImageView.image = [JKRFeedDetailHelper imageNamed:@"tab_dibu"];
    }
    return _backgroundImageView;
}

- (UIButton *)commentButton {
    if (!_commentButton) {
        _commentButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_commentButton setImage:[JKRFeedDetailHelper imageNamed:@"xq_pj"] forState:UIControlStateNormal];
        _commentButton.frame = CGRectMake(0, 4, kScreenWidth / 3.0, 52);
        [_commentButton addTarget:self action:@selector(commentButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _commentButton;
}

- (UIButton *)voteButton {
    if (!_voteButton) {
        _voteButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_voteButton setImage:[JKRFeedDetailHelper imageNamed:@"xq_dzhui"] forState:UIControlStateNormal];
        [_voteButton setImage:[JKRFeedDetailHelper imageNamed:@"xq_dzh"] forState:UIControlStateSelected];
        _voteButton.frame = CGRectMake(kScreenWidth / 3.0, 4, kScreenWidth / 3.0, 52);
    }
    return _voteButton;
}

- (UIButton *)shareButton {
    if (!_shareButton) {
        _shareButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_shareButton setImage:[JKRFeedDetailHelper imageNamed:@"xq_fx"] forState:UIControlStateNormal];
        _shareButton.frame = CGRectMake(kScreenWidth - kScreenWidth / 3.0, 4, kScreenWidth / 3.0, 52);
    }
    return _shareButton;
}


@end
